﻿
using System;
using My.Ioc.Condition;
using My.Ioc.Configuration.Injection;
using My.Ioc.Core;
using My.Ioc.Lifetimes;

namespace My.Ioc.Configuration.FluentApi
{
    public interface ICommonConfigurationApi : IWhenApi
    {
    }



    // Configuration Api for Conditional Binding
    public interface IWhenApi : IInApi
    {
        IInApi WhenMatchCondition(Predicate<IInjectionInfo> condition);

        IInApi WhenHasNoParent();
        IInApi WhenParentTypeIsAny(params Type[] parentTypes);
        IInApi WhenParentTypeIs(Type parentType);
        IInApi WhenParentTypeIs<TParent>();
        IInApi WhenParentMetadata(Predicate<object> metadataCondition);

        IInApi WhenTargetHasAttribute(Type attributeType);
        IInApi WhenTargetHasAttribute<TAttribute>() where TAttribute : Attribute;
        IInApi WhenTargetNamed(string name);
    }
    // Configuration Api for Lifetime
    public interface IInApi : ISetApi
    {
        ISetApi In(ILifetimeProvider lifetimeProvider);
    }
    // Configuration Api for ObjectDescription
    public interface ISetApi : IReturnApi
    {
        IReturnApi Set(object metadata);
        IReturnApi Set(int ranking);
        IReturnApi Set(object metadata, int ranking);
    }
    // Configuration Api for IObjectBuilderRegistration
    public interface IReturnApi : IApi
    {
        IApi Return(out IObjectRegistration registration);
        IApi Return<T>(out IObjectRegistration<T> registration);
    }

    public interface IApi
    {
        Kernel Kernel { get; }
        InjectionConfigurationSet InjectionConfigurationSet { get; }
    }
}
